<% breadcrumb :sellers %>
<script type="text/javascript">
function validate_form(thisform)
{
  var fileName = document.forms["fileForm"]["seller_file"].value;
  if (fileName){
    return true;
  }
  else{
    alert('请选择要上传的文件');
    return false;
  }
}
</script>

<div class="row">
  <div class="col-lg-12">
    <div class="ibox float-e-margins">
      <div class="ibox-title">
        <h5>销售列表</h5>
      </div>
      <div class="ibox-content">
        <div class="project-list">

          <div class="row">
            <div class="col-sm-8">
              <form action="/app/events/<%= current_event.id %>/sellers" class='form-inline' method="post" name="fileForm" multipart='true' enctype="multipart/form-data" onsubmit="return validate_form(this);">
                <div class="form-group">
                  <%= file_field_tag :seller_file, accept: ".xls", class: 'btn btn-white btn-sm ' %>
                </div>
                <input type="submit" value="导入" class="btn btn-white btn-sm ">
              </form>
            </div>

            <div class="col-sm-2">
              <%= link_to '下载模板', templates_path(filename: 'seller.xls'), class: 'btn btn-white btn-sm pull-right' %>
            </div>
            <div class="col-sm-2">
              <%= link_to '新增销售', new_event_seller_path, class: 'btn btn-white btn-sm pull-right' %>
            </div>

          </div>

          <div class="row">
          <table class="table table-hover">
            <thead>
            <tr>
              <th>姓名</th>
<!--               <th>负责区域</th>
              <th>销售主管</th> -->
              <th>电话号码</th>
              <th>操作</th>
            </tr>
            </thead>

            <tbody>
            <% @sellers.each do |seller| %>
            <tr>
              <td>
                <%= seller.name %>
              </td>
              <td>
                <%= seller.phone_number %>
              </td>
              <td class="text-center">
                <%= link_to edit_event_seller_path(current_event, seller), class: 'btn btn-white btn-sm' do%>
                <i class="fa fa-pencil"></i> 修改
                <% end %>

                <%= link_to event_seller_path(current_event, seller), method: :delete, data: {confirm: '是否确认删除？'}, class: 'btn btn-white btn-sm' do %>
                  <i class="fa fa-trash"></i> 删除
                <% end %>
              </td>
            </tr>
            <% end %>

            </tbody>
          </table>
          </div>

        <div class="row">
          <div class="col-sm-12">
            <%= paginate @sellers %>
          </div>
        </div>
        </div>

      </div>
    </div>
  </div>
</div>